﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Taoyl.CodeTraceControlLib
{
    public partial class DayProduction : UserControl
    {
        public DayProduction()
        {
            InitializeComponent();
            this.SetStyle(ControlStyles.AllPaintingInWmPaint, true);
            this.SetStyle(ControlStyles.DoubleBuffer, true);
            this.SetStyle(ControlStyles.ResizeRedraw, true);
            this.SetStyle(ControlStyles.Selectable, true);
            this.SetStyle(ControlStyles.SupportsTransparentBackColor, true);
            this.SetStyle(ControlStyles.UserPaint, true);
        }

        private string titleName = "日产量统计";
        [Browsable(true)]
        [Category("自定义属性")]
        [Description("设置或获取标题名称")]
        public string TitleName
        {
            get { return titleName; }
            set { titleName = value; this.lbl_Title.Text = titleName; }
        }

        private int totalProduction=1000;
        [Browsable(true)]
        [Category("自定义属性")]
        [Description("设置或获取总产量")]
        public int TotalProduction
        {
            get { return totalProduction; }
            set { 
                if (totalProduction!=value)
                {
                   totalProduction = value;
                    this.meter_Production.MaxValue = totalProduction;
                    this.lbl_Total.Text=totalProduction.ToString("N0");
                }
            }
        }

        private int currentProduction = 600;
        [Browsable(true)]
        [Category("自定义属性")]
        [Description("设置或获取当前产量")]
        public int CurrentProduction
        {
            get { return currentProduction; }
            set
            {
                if(currentProduction>10000)
                {
                    value = 9999;
                }
                if (currentProduction != value)
                {
                    currentProduction = value;
                    this.meter_Production.ActualValue = currentProduction;
                    string showValue=currentProduction.ToString().PadLeft(4, '0');
                    this.lbl_P1.Text = showValue[0].ToString();
                    this.lbl_P2.Text = showValue[1].ToString();
                    this.lbl_P3.Text = showValue[2].ToString();
                    this.lbl_P4.Text = showValue[3].ToString();
                }
            }
        }
    }
}
